<?php

class Contact_us extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->library(array(
            'form_validation',
            'email'
        ));
    }
    
    public function index() {
        
        $this->form_validation->set_rules('name', 'Name', 'required');
        $this->form_validation->set_rules('email', 'Email', 'required');
        $this->form_validation->set_rules('comments', 'Comments', 'required');
        
        if($this->form_validation->run() == FALSE) {
            
        } else {
            $this->email->from('mail@mail.com', 'Nombre');
            $this->email->to('hernanbalboa@gmail.com');
            $this->email->subject('Asunto');
            
            $mensaje = 'Name: '.$this->input->post('name').'
Last: '.$this->input->post('last').'
Company: '.$this->input->post('company').'
Country: '.$this->input->post('country').'
Telephone: '.$this->input->post('telephone').'
Mail Address: '.$this->input->post('email').'
Radio
Comments: '.$this->input->post('comments');
            $this->email->message($mensaje);
            
            $this->email->send();
        }
        
        $this->load->view('layout/header');
        $this->load->view('contact_us/index');
        $this->load->view('layout/frases');
        $this->load->view('layout/footer');
    }
}
?>
